export function request(url, data = {}, method = 'GET') {
	let root_url = 'http://localhost:3000'
	// let root_url = 'http://vbs9ev.natappfree.cc'
	return new Promise((resolve, reject) => {
		let cookies = uni.getStorageSync('cookie')
		let token = uni.getStorageSync('token')
		uni.showLoading({
			title: '加载中',
		})
		uni.request({
			url: root_url + url,
			method: method,
			data: data,
			dataType: 'json',
			header: {
				cookies: cookies,
				token: token
			},
			withCredentials: true,
			success: (value) => {
				uni.hideLoading()
				resolve(value['data'])
			},
			fail: (err) => {
				uni.showToast({
					title: '加载失败',
					icon: 'error'
				})
				reject(err)
			}
		})
	})
}
